/*
 * @Author: baoyiwen 511530203@qq.com
 * @Date: 2025-04-25 15:36:58
 * @LastEditors: baoyiwen 511530203@qq.com
 * @LastEditTime: 2025-05-14 17:28:34
 * @FilePath: \neilao-mobile\src\api\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import axios from 'axios'
import { http, axiosInstance } from '../utils/request'
// 测试环境地址
// const BASE_URL_POST = `http://192.168.0.21:9070`;
const BASE_URL_POST = `http://113.250.182.106:8001`
// const BASE_URL_POST = `https://csts.zfcxjw.cq.gov.cn:38001`;
// const BASE_URL_POST = `http://113.250.182.106:8001/command-centre-mobile/xyJinan`
const BASE_AUTH_CODE = `http://113.250.182.106:8001/command-centre-mobile/xyJinan`
const BASE_First_URL = `http://113.250.182.106:8001`
const BASE_FIRST_URL_DEV = `http://113.250.182.106:8001`
// 巡查养护-辨识
// const baseUrl = 'http://113.250.182.106:8001/risk-identify-web/api'
const BASE_IDENTIFY = 'http://192.168.0.37:8628'

// 正式环境地址
// const BASE_URL_POST = `https://csts.zfcxjw.cq.gov.cn:38001`
// const BASE_AUTH_CODE = `https://csts.zfcxjw.cq.gov.cn:38001`
// const BASE_First_URL = `https://csts.zfcxjw.cq.gov.cn:38001`
// const BASE_FIRST_URL_DEV = `https://csts.zfcxjw.cq.gov.cn:38001`
// const BASE_IDENTIFY = 'http://23.24.203.124:8001/risk-identify-web/api'
const BASE_URL = `/early-warning-web/zyAuthApi/auth/b/getPicCaptcha`
const BASE_LOGIN_URL = `/command-centre-mobile/zyAuthApi/auth/b/doLogin`
const BASE_USER_INFO_URL = '/system-maintain/zyAuthApi/auth/b/getLoginUser'
const BASE_TOKEN = `/system-maintain/zyAuthApi/auth/b/zzd/secretFree/doLogin`
// const BASE_URL_TOKEN = `http://192.168.0.39:9070`;
import { getDataToken as getToken } from '../utils/userInfo'
import sm from '../utils/sm-crypto'
const token = getToken()
export const config = () => {
  return {
    BASE_IDENTIFY,
  }
}

export const getPicCaptcha = () => {
  return http.get(`${BASE_First_URL}${BASE_URL}`)
  // return axios({
  //   url: `${BASE_First_URL}${BASE_URL}`,
  //   method: "get",
  // });
}
export const doLogin = (loginInfo) => {
  const body = { ...loginInfo }
  body.device = body.device || 'PC'
  body.password = sm.doSm2Encrypt(loginInfo.password)
  return http.post(`${BASE_First_URL}${BASE_LOGIN_URL}`, body)
  // return axios({
  //   url: `${BASE_First_URL}${BASE_LOGIN_URL}`,
  //   method: "post",
  //   data: {
  //     ...body,
  //   },
  // });
}

export const getUserInfo = (token) => {
  // return http.get(`${BASE_First_URL}${BASE_USER_INFO_URL}`, {
  //   headers: {
  //     token: token,
  //   },
  // });
  return axios({
    url: `${BASE_FIRST_URL_DEV}${BASE_USER_INFO_URL}`,
    method: 'get',
    headers: {
      token: token,
    },
  })
}

export const getTokenByCode = (code) => {
  // return http.post(`${BASE_First_URL}${BASE_TOKEN}`, {
  //   authCode: code,
  // })
  return axios({
    url: `${BASE_FIRST_URL_DEV}${BASE_TOKEN}`,
    method: 'post',
    data: {
      authCode: code,
    },
  })
}
export const getDisposeList = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/biz/work/workList`, data)
  // return http.post(`${BASE_URL_POST}/cqwl/biz/work/list`, data)
  //处置列表
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/biz/work/list`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  //   data: data,
  // });
}
export const getWorkDetail = (id) => {
  return http.post(`${BASE_URL_POST}/cqwl/biz/work/getWorkById/${id}`)
  //获取详情
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/biz/work/getWorkById/${id}`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  // });
}
export const feedback = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/biz/work/feedback`, data)
  //处置反馈
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/biz/work/feedback`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  //   data: data,
  // });
}

export const getList = (ids) => {
  return axios({
    url: `${BASE_URL_POST}/cqwl/biz/inspectionMatters/listByIds/${ids}`,
    method: 'get',
  })
}
export const getListYd = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/re/work/listYd`, data)
}
export const completion = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/biz/work/completion`, data)
  //提交办结
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/biz/work/completion`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  //   data: data,
  // });
}

// 获取响应工单列表
export const getResponseList = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/re/work/listYd`, data)
  // return http.post(
  //   `${BASE_URL_POST}/cqwl/re/work/list?pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
  //   data,
  // )
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/re/work/list?pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  //   data,
  // });
}

// 获取响应工单详情
export const getResponseWordDetail = (id) => {
  return http.post(`${BASE_URL_POST}/cqwl/re/work/todo/${id}`)
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/re/work/todo/${id}`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  // });
}
// 获取响应工单详情
export const getInspectionMatters = (id) => {
  return http.get(`${BASE_URL_POST}/cqwl/biz/inspectionMatters/listByIds/${id}`)
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/re/work/todo/${id}`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  // });
}

// 获取响应工单详情
export const getWorkTimelineDetail = (id) => {
  return http.post(
    `${BASE_URL_POST}/cqwl/operationLogQueryController/getWorkTimelineDetail?id=${id}`,
  )
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/re/work/todo/${id}`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  // });
}

// 确认响应
export const editWorkStatus = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/re/work/editWorkStatus`, data)
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/re/work/editWorkStatus`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  //   data,
  // });
}

// 上传
export const upload = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/file/upload`, data)
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/file/upload`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  //   data,
  // });
}

// 确认到场
export const confirmAttendance = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/biz/work/confirmAttendance`, data)
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/biz/work/confirmAttendance`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  //   data,
  // });
}

export const getDataToken = (token) => {
  return axios({
    url: `${BASE_URL_POST}/cqwl/biz/baseplat/getToken/${token}`,
    method: 'get',
  })
}
// 是否在库，选择在库时，根据用户地区code获取点位列表
export const getPointPlus = (code) => {
  return http.post(`${BASE_URL_POST}/cqwl/biz/yj/History/pointPlus/${code}`)
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/biz/yj/History/pointPlus/${code}`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  // });
}

// 快处上报
export const speedinessReport = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/biz/work/speedinessReport`, data)
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/biz/work/speedinessReport`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  //   data,
  // });
}

// 根据等级获取处置情况
export const dangerClasses = (level) => {
  return http.post(`${BASE_URL_POST}/cqwl/biz/work/dangerClasses/${level}`)
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/biz/work/dangerClasses/${level}`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  // });
}
// 获取班组

export const getBzOptions = (data) => {
  return http.post(`${BASE_URL_POST}/cqwl/re/yj/Class/findClass`, data)
  // return axios({
  //   url: `${BASE_URL_POST}/cqwl/re/yj/Class/findClass`,
  //   method: "post",
  //   headers: {
  //     token: token,
  //   },
  //   data,
  // });
}
